/*
 * Copyright (c) 2021. Moses All Right Reserved
 */

package com.moses.design_patterns.adapter.class_adapter;

import com.moses.design_patterns.adapter.object_adapter.ObjectAdapter;

/**
 * @author Moses
 * @email shenhuohui@gmail.com
 * @date 2021/4/12 23:51
 */
public class Client {
    public static void main(String[] args) {
        // 原始
        ITarget target = new Target();
        System.out.println("age:" + target.getAge());
        System.out.println("gender:" + target.getGender());
        System.out.println("====================");

        // 1. 类适配器，通过继承要转换的类 Adaptee 和实现目标类的接口 ITarget 进行转换
        // 适配器与 Adaptee 是继承关系
        target = new Adapter();
        System.out.println("age:" + target.getAge());
        System.out.println("gender:" + target.getGender());

        System.out.println("====================");

        // 2. 对象适配器，通过继承目标类，在传入要转换的类
        // 适配器和 Adaptee 是关联关系
        target = new ObjectAdapter(new Adaptee());
        System.out.println("age:" + target.getAge());
        System.out.println("gender:" + target.getGender());
    }
}
